home *** CD-ROM | disk | FTP | other *** search
- { O.K. Sharp here with another explaination program....
- This one shows how the famous moving circles is done.
- The idea on how to do this was completely mine (but I ofcource wasn't
- the first to do this),
- it's done in EGA but if you know how to program the VGA card
- you should be able to change this to VGA but DO remind yourself
- that the VGA handles it's latches different than the EGA so you'll
- have to change the aproach. The nice thing about it is that you can
- simulate an 8 plane screen but you'l only will be able to draw 4 pixels
- at a time!!. Well try it out for yourself if you figure out how to do it,
- in the meanwhile stick to this:-)...
- }
-
- {$G+}
- uses crt;
-
- { circle.obj contains the information for the circle. Every bit is a pixel
- so if a byte contains 01010101b a dotted line of 8 pixels wil be drawn.
- the size is 640 x 350 bits.. (28000 bytes) }
- {$L circles.obj }
- {$F+ }
- procedure circleega; external;
- {$F- }
-
- { draws a circle, x,y is the starting point in the buffer (left-top),
- plane is the plane in which to draw the circles:
- there are four planes:
- plane 0 => this will result in blue circles,
- plane 1 => this will result in green circles,
- plane 2 => this will result in red circles,
- plane 3 => this will result in gray circles...
- When circles overlap the colors of the circles will be blend...}
-
- procedure drawcircle(x,y : integer; plane : byte);
- label loop1,loop2;
- begin
- asm;
- push ds
-
- mov al,02h { mask register }
- mov ah,1
- mov cl,plane { plane nr }
- and cl,00000011b { plane nr 0-3 !! }
- shl ah,cl { 1 shifted by plane => mask }
- mov dx,3c4h
- out dx,ax { out to port.. }
-
- mov ax,0a000h { VGA mem.. }
- mov es,ax { in es. }
- mov ax,seg(circleega) { segment containing circle data..}
- mov ds,ax { in ds. }
-
- mov di,0 { pos 0 in screen mem... }
-
- mov si,x { si => x pos }
- shr si,3 { x-pos div 8 => x-point in mem.. }
- mov ax,y { ax => y }
- mov bx,80
- mul bx { y * 80 => y-point in mem.. }
- add si,ax { x+y*80 => pos. in buffer }
- add si,offset circleega { add offset buffer.. }
- mov bx,0 { clear bx }
- loop1:
- mov cx,40 { 40 points in mem.. }
- rep movsb { copy to mem. }
- add si,40 { adjust si for next line.. }
- inc bx { next line }
- cmp bx,200 { last line reached? }
- jb loop1 { no, then do another one.. }
-
- pop ds
- end;
- end;
-
- var cnt : integer;
- afvang : char;
-
- begin
- asm
- mov ax,13 { 320 x 200 x 16 EGA... }
- int 10h { and make it so. }
- end;
-
- { start with 0 degrees }
- cnt:=0;
-
- repeat
- { draw a green circle }
- drawcircle(160+round(150*cos(cnt*PI / 100)),75+round(75*sin(cnt*PI / 100)),1);
- { and make a gray circle }
- drawcircle(160+round(75*(cos(cnt*PI / 100))+cos((50+cnt)*PI/100)),75+round(37*(sin(cnt*PI / 100)+sin((cnt+50)*PI/100))),3);
-
- { 200 degrees and the fun starts over...}
- inc(cnt);
- if cnt=200 then cnt:=0;
- until keypressed;
-
- afvang:=readkey; { clean da keybuffer.. }
-
- { and back to text mode... }
- asm
- mov ax,3
- int 10h
- end;
- end.